﻿<local:ValidStateUserControl x:Class="DBLint.DBLintGui.SelectRules"
                             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                             xmlns:local="clr-namespace:DBLint.DBLintGui"
                             mc:Ignorable="d"
                             d:DesignHeight="300"
                             d:DesignWidth="300">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="25" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <GroupBox Header="Rule Types">
                <ListView ItemsSource="{Binding RuleSets}"
                          IsSynchronizedWithCurrentItem="True"
                          Name="rulesSetsView">
                    <ListView.ItemTemplate>
                        <DataTemplate DataType="{x:Type local:RuleSet}">
                            <StackPanel Orientation="Horizontal"
                                        Margin="5">
                                <CheckBox IsChecked="{Binding Include}"
                                          Margin="0,2,0,0"
                                          Name="includeRuleSet"
                                          Checked="includeRuleSet_Checked"
                                          Unchecked="includeRuleSet_Unchecked"
                                          Indeterminate="includeRuleSet_Indeterminate" />
                                <TextBlock Text="{Binding Name}"
                                           Margin="5,1,0,1" />
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </GroupBox>
            <Button Grid.Row="1"
                    Content="_Reset Configurations"
                    Name="ResetConfigurationButton"
                    Click="ResetConfigurationButton_Click" />
            <Button Grid.Row="2"
                    Content="New user-defined rule"
                    Name="NewRuleButton"/>
            <Label Grid.Row="3"></Label>
            <Button Grid.Row="4"
                    Content="Export Configuration..."
                    Name="SaveConfigButon"/>
            <Button Grid.Row="5"
                    Content="Import Configuration..."
                    Name="LoadConfigButon"/>
        </Grid>

        <GroupBox Grid.Column="1"
                  Header="Rules">
            <ListView  ItemsSource="{Binding RuleSets/Rules}"
                       ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                       Grid.IsSharedSizeScope="True" DataContext="{Binding}" Name="RuleListView">
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="Focusable"
                                Value="false" />
                        <Setter Property="HorizontalContentAlignment"
                                Value="Stretch" />
                        <Setter Property="HorizontalAlignment"
                                Value="Stretch" />
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.ItemTemplate>
                    <DataTemplate DataType="{x:Type local:Rule}">
                        <Grid Grid.IsSharedSizeScope="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition SharedSizeGroup="B" />
                                <ColumnDefinition SharedSizeGroup="B" />
                            </Grid.ColumnDefinitions>
                            <CheckBox IsChecked="{Binding Include}"
                                      Margin="5"
                                      Name="includeRule"
                                      Click="includeRule_Click"
                                      Template="{StaticResource noAnimationControlTemplate}"
                                      OverridesDefaultStyle="True">
                                <TextBlock Text="{Binding Name}" />
                            </CheckBox>
                            <Label Grid.Column="1"
                                   Name="deleteLabel"
                                   IsEnabled="{Binding IsDeletable}" Mouse.MouseDown="deleteLabel_MouseDown">
                                <TextBlock Name="deleteTxt"
                                           Foreground="Blue">
                                    Delete
                                </TextBlock>
                            </Label>
                            <Label Grid.Column="2"
                                   Name="configureLabel"
                                   Mouse.MouseDown="configureLabel_MouseDown"
                                   IsEnabled="{Binding IsConfigureable}">
                                <TextBlock Name="txt"
                                           Foreground="Blue">
                                    Configure
                                </TextBlock>
                            </Label>
                        </Grid>
                        <DataTemplate.Triggers>
                            <Trigger SourceName="configureLabel"
                                     Property="IsMouseOver"
                                     Value="True">
                                <Setter TargetName="configureLabel"
                                        Property="Cursor"
                                        Value="Hand" />
                                <Setter TargetName="txt"
                                        Property="TextDecorations"
                                        Value="{x:Static TextDecorations.Underline}" />
                            </Trigger>
                            <Trigger SourceName="configureLabel"
                                     Property="IsEnabled"
                                     Value="False">
                                <Setter TargetName="configureLabel"
                                        Property="Visibility"
                                        Value="Hidden" />
                            </Trigger>
                            <Trigger SourceName="deleteLabel"
                                     Property="IsMouseOver"
                                     Value="True">
                                <Setter TargetName="deleteLabel"
                                        Property="Cursor"
                                        Value="Hand" />
                                <Setter TargetName="deleteTxt"
                                        Property="TextDecorations"
                                        Value="{x:Static TextDecorations.Underline}" />
                            </Trigger>
                            <Trigger SourceName="deleteLabel"
                                     Property="IsEnabled"
                                     Value="False">
                                <Setter TargetName="deleteLabel"
                                        Property="Visibility"
                                        Value="Hidden" />
                            </Trigger>
                        </DataTemplate.Triggers>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </GroupBox>

    </Grid>
</local:ValidStateUserControl>